/*
 * Solution.h
 *
 *  Created on: Apr 6, 2011
 *      Author: hxu
 *      solution for buffer insertion at a Treenode
 */

#ifndef SOLUTION_H_
#define SOLUTION_H_
#include <map>
#include<vector>
#include "Tree.h"
#define SOLUTION_NUM_TYPE int

namespace Cxuh {

struct Bufsol{
	// buffer solution for a TreeNode
	double q;	// maximum required time
	double c;	// total lumped capacitance
	double P;	// power
	double slew;	// input slew rate
	int buftype;	// buffer type for this solution, 0 = no buffer
	int id; // id of the node
};

class Solution {
public:
	Solution();
	Solution(const Tree<SOLUTION_NUM_TYPE>& tree1);	// initiate for a tree
	virtual ~Solution();
	void setBufsol(Bufsol *bs, int id, int buftype, double q, double c, double P, double slew);	// set the content of a solution
	//void initSolution(const Tree<SOLUTION_NUM_TYPE>& tree1, TreeNode<SOLUTION_NUM_TYPE> *node);	// initialization for a subtree after rooted at the node
	template<class Type> void initSolution(const Tree<Type>& tree1, TreeNode<Type> *node);	// initialization for a subtree after rooted at the node
	std::vector<Cxuh::Bufsol>* getValue(); // return value
	friend std::ostream& operator << (std::ostream&, Solution&);
private:
	int treeid;	// the id of the corresponding tree
	std::map<int, std::vector<Cxuh::Bufsol> > value;
};

}

#endif /* SOLUTION_H_ */
